<!Doctype html>  
<html lang="en">  
 <head>  
  <meta charset="UTF-8">  
  <title>Window对象定时设定和时间间隔</title>  
 </head>  
 <body>  
<script type="text/javascript">  
function display(){
	var content = document.getElementById("text");
	content.value = new Date().toLocaleString();
}
window.onload = function(){
	var timer;
	document.getElementById("start").onclick = function(){
		timer = setInterval('display()',1000);
	};
	document.getElementById("stop").onclick = function(){
		clearInterval(timer);
	};
}
</script> 
<input type="text" value="" id="text" size="30">
<input type="button" value="开始" id="start">
<input type="button" value="结束" id="stop">
</body>  
</html> 